﻿/* DotNetHoldem 
 * .Net Solution that allows to use OpenHoldem with .Net logic
 * Author: Óscar Andreu
 * oesido at gmail dot com
 * Licensed under GPLv3 - 2012
 */

using System;
using System.Runtime.InteropServices;
using wd2now.Framework.Legacy.Enums;

namespace wd2now.Framework.Legacy.Classes
{
    public class OH_Wrapper
    {
        #region OH function delegates


        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        private delegate double GetSymbolFromDllDelegate(int chair, string symbol);
        GetSymbolFromDllDelegate getSymbolFromDll;

        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        private delegate string GetPlayerNameDelegate(int chair);
        GetPlayerNameDelegate getPlayerName;

        #endregion

        public OH_Wrapper(IntPtr getSymbolFromDll, IntPtr getPlayerName)
        {
            this.getSymbolFromDll = (GetSymbolFromDllDelegate)Marshal.GetDelegateForFunctionPointer(getSymbolFromDll, typeof(GetSymbolFromDllDelegate));
            this.getPlayerName = (GetPlayerNameDelegate)Marshal.GetDelegateForFunctionPointer(getPlayerName, typeof(GetPlayerNameDelegate));
        }
      
        internal string GetPlayerName(int chair)
        {
            return this.getPlayerName(chair);
        }

        internal double GetSym(int chair, string symbolName)
        {
            return this.getSymbolFromDll(chair, symbolName);
        }

        public double GetSymbol(Symbols symbol)
        {
            return GetSym(0, symbol.ToString());
        }

        
    }

}
